package factorycase.simplefactory;

/**
 * @Description:工厂类角色
 * @Author: csh
 * @CreateDate: 2018/8/20$ 11:59$
 * @Version: 1.0
 */
public class Driver {
    /**工厂方法，注意返回类型为抽象产品角色*/
    public static Car driverCar(String s)throws Exception{
        /*判断逻辑，返回具体的产品角色给client*/
        if(s.equalsIgnoreCase("Benz")){
            return new Benz();
        }else if(s.equalsIgnoreCase("Bmw")){
            return new Bmw();
        }else{
            throw new Exception();
        }
    }
}
